package game.ui.core
{
	import engine.asset.*;
	import engine.core.*;
	import flash.display.*;
	import flash.geom.*;
	import flash.ui.*;
	
	public class RxUICursor
	{
		public static const NO_CURSOR:String = null;
		public static const DEFAULT:String = "default";
		public static const ATTACK:String = "attack";
		public static const SPECIAL_ATTACK:String = "specialAttack";
		public static const TALK:String = "talk";
		public static const INTERACTIVE:String = "interactive";
		public static const DRAGGABLE:String = "draggable";
		public static const DRAGGING:String = "dragging";
		public static const LOADING:String = "loading";
		public static const TEXT_CURSOR:String = "textCursor";
		private static var s_stateArray:Array;
		private static var s_lockCursor:Boolean = false;
		
		public function RxUICursor()
		{
		}
		
		public static function SetState(param1:String, param2:int = 1) : void
		{
			if (s_stateArray && s_stateArray[param2] != param1)
			{
				if (param1 == NO_CURSOR)
				{
					s_stateArray[param2] = null;
				}
				s_stateArray[param2] = param1;
				if (!s_lockCursor)
				{
					CommitState();
				}
			}
			if (RxClientVars.GetInt("videoCaptureSetup") == 1)
			{
				if (RxKeyboard.isDown(RxKeyboard.KEY_SHIFT) && RxKeyboard.isPressed(RxKeyboard.KEY_M))
				{
					Mouse.show();
				}
				else if (RxKeyboard.isPressed(RxKeyboard.KEY_M))
				{
					Mouse.hide();
				}
			}
		}
		
		private static function CommitState() : void
		{
			var _loc_1:* = GetCursorState();
			if (_loc_1 == TEXT_CURSOR)
			{
				_loc_1 = MouseCursor.IBEAM;
			}
			Mouse.cursor = _loc_1;
		}
		
		public static function GetCursorState() : String
		{
			var _loc_1:String = null;
			var _loc_2:* = s_stateArray.length - 1;
			while (_loc_2 >= 0)
			{
				
				_loc_1 = s_stateArray[_loc_2];
				if (_loc_1 != null)
				{
					break;
				}
				_loc_2 = _loc_2 - 1;
			}
			if (_loc_1 == null)
			{
				_loc_1 = DEFAULT;
			}
			return _loc_1;
		}
		
		public static function GetAssetLoaderForCursors() : RxAssetGroup
		{
			var _loc_1:* = new RxAssetGroup();
			_loc_1.AddAsset(RxAssetImage.Create("ui/cursors/cursor_grab.png", null));
			_loc_1.AddAsset(RxAssetImage.Create("ui/cursors/cursor_grabbed.png", null));
			_loc_1.AddAsset(RxAssetImage.Create("ui/cursors/cursor_attack_sword.png", null));
			_loc_1.AddAsset(RxAssetImage.Create("ui/cursors/cursor_hand_open.png", null));
			_loc_1.AddAsset(RxAssetImage.Create("ui/cursors/cursor_pointer.png", null));
			_loc_1.AddAsset(RxAssetImage.Create("ui/cursors/cursor_talk_to_npc.png", null));
			return _loc_1;
		}
		
		public static function Initialize() : void
		{
			var _loc_3:RxAssetImage = null;
			var _loc_4:BitmapData = null;
			var _loc_5:Vector.<BitmapData> = null;
			var _loc_6:MouseCursorData = null;
			s_stateArray = [NO_CURSOR, NO_CURSOR, NO_CURSOR];
			var _loc_1:Array = [DEFAULT, ATTACK, SPECIAL_ATTACK, TALK, INTERACTIVE, DRAGGABLE, DRAGGING];
			var _loc_2:Array = ["ui/cursors/cursor_pointer.png", "ui/cursors/cursor_attack_sword.png", "ui/cursors/cursor_attack_sword.png", "ui/cursors/cursor_talk_to_npc.png", "ui/cursors/cursor_hand_open.png", "ui/cursors/cursor_grab.png", "ui/cursors/cursor_grabbed.png"];
			var _loc_7:int = 0;
			while (_loc_7 < _loc_2.length)
			{
				
				_loc_3 = RxAssetImage.Create(_loc_2[_loc_7], null);
				if (!_loc_3)
				{
				}
				else
				{
					_loc_4 = _loc_3.GetBitmapData();
					if (!_loc_4)
					{
					}
					else
					{
						_loc_6 = new MouseCursorData();
						_loc_5 = new Vector.<BitmapData>(1, true);
						_loc_5[0] = _loc_4;
						_loc_6.data = _loc_5;
						_loc_6.hotSpot = new Point(0, 0);
						Mouse.registerCursor(_loc_1[_loc_7], _loc_6);
					}
				}
				_loc_7++;
			}
		}
	}
}